﻿<Window x:Class="fleetIt.MainUI"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:fleetIt="clr-namespace:fleetIt"
    xmlns:fleetItCore="clr-namespace:fleetIt.Core"
    Title="fleetIt" Height="650" Width="375" 
    WindowStartupLocation="CenterScreen"
    ResizeMode="CanMinimize" Loaded="Window_Loaded" Icon="/Images/logo.ico" 
    Closing="Window_Closing" StateChanged="Window_StateChanged"
    WindowStyle="SingleBorderWindow">
    <Window.CommandBindings>
        <CommandBinding x:Name="AboutCommand" Command="fleetIt:Commands.About" 
                        CanExecute="AboutCommand_CanExecute" Executed="AboutCommand_Executed" />
        <CommandBinding x:Name="RefreshCommand" Command="fleetIt:Commands.Refresh"
                        CanExecute="RefreshCommand_CanExecute" Executed="RefreshCommand_Executed" />
        <CommandBinding x:Name="ExitCommand" Command="fleetIt:Commands.Exit" 
                        CanExecute="ExitCommand_CanExecute" Executed="ExitCommand_Executed" />
        <CommandBinding x:Name="UnderlineCommand" Command="fleetIt:Commands.Underline" 
                        CanExecute="UnderlineCommand_CanExecute" Executed="UnderlineCommand_Executed" />
        <CommandBinding x:Name="BoldCommand" Command="fleetIt:Commands.Bold"
                        CanExecute="BoldCommand_CanExecute" Executed="BoldCommand_Executed" />
        <CommandBinding x:Name="ItalicCommand" Command="fleetIt:Commands.Italic" 
                        CanExecute="ItalicCommand_CanExecute" Executed="ItalicCommand_Executed" />
        <CommandBinding x:Name="StrikeThroughCommand" Command="fleetIt:Commands.StrikeThrough" 
                        CanExecute="StrikeThroughCommand_CanExecute" Executed="StrikeThroughCommand_Executed" />
        <CommandBinding x:Name="InsertLinkCommand" Command="fleetIt:Commands.InsertLink" 
                        CanExecute="InsertLinkCommand_CanExecute" Executed="InsertLinkCommand_Executed" />
        <CommandBinding x:Name="PasteCommand" Command="fleetIt:Commands.Paste" 
                        CanExecute="PasteCommand_CanExecute" Executed="PasteCommand_Executed" />
        <CommandBinding x:Name="SignInCommand" Command="fleetIt:Commands.SignIn" 
                        CanExecute="SignInCommand_CanExecute" Executed="SignInCommand_Executed" />
        <CommandBinding x:Name="FleetMyStatusCommand" Command="fleetIt:Commands.FleetMyStatus" 
                        CanExecute="FleetMyStatusCommand_CanExecute" Executed="FleetMyStatusCommand_Executed" />
        <CommandBinding x:Name="ProfileCommand" Command="fleetIt:Commands.Profile" 
                        CanExecute="ProfileCommand_CanExecute" Executed="ProfileCommand_Executed" />
        <CommandBinding x:Name="ReplyFleetCommand" Command="fleetIt:Commands.ReplyToFleet" 
                        CanExecute="ReplyFleetCommand_CanExecute" Executed="ReplyFleetCommand_Executed" />
        <CommandBinding x:Name="MarkAsFavCommand" Command="fleetIt:Commands.MarkFavoriteFleet" 
                        CanExecute="MarkAsFavCommand_CanExecute" Executed="MarkAsFavCommand_Executed" />
        <CommandBinding x:Name="DeleteCommand" Command="fleetIt:Commands.DeleteFleet" 
                        CanExecute="DeleteCommand_CanExecute" Executed="DeleteCommand_Executed" />
        <CommandBinding x:Name="SettingsCommand" Command="fleetIt:Commands.Settings" 
                        CanExecute="SettingsCommand_CanExecute" Executed="SettingsCommand_Executed" />
        <CommandBinding x:Name="VersionCommand" Command="fleetIt:Commands.Version" 
                        CanExecute="VersionCommand_CanExecute" Executed="VersionCommand_Executed" />
    </Window.CommandBindings>
    <Window.Resources>
        <fleetItCore:ImageCacher x:Key="ImageCacher" />
        <fleetItCore:CharacterCounter x:Key="CharacterCounter" />
    </Window.Resources>
    <Window.Background>
        <LinearGradientBrush>
            <GradientStop Color="DodgerBlue" Offset="0.0" />
            <GradientStop Color="White" Offset="0.7" />
        </LinearGradientBrush>
    </Window.Background>
    <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0">
            <MenuItem Header="_File">
                <MenuItem Header="_Exit" Command="fleetIt:Commands.Exit"/>
            </MenuItem>
            <MenuItem Header="_View">
                <MenuItem Header="_Refresh" Command="fleetIt:Commands.Refresh">
                    <MenuItem.Icon>
                        <Image Source="/images/arrow_refresh.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="_Options">
                <MenuItem Header="_Reply" Command="fleetIt:Commands.ReplyToFleet">
                    <MenuItem.Icon>
                        <Image Source="/images/arrow_rotate_anticlockwise.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="_Favorite" Command="fleetIt:Commands.MarkFavoriteFleet">
                    <MenuItem.Icon>
                        <Image Source="/images/star.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="_Delete" Command="fleetIt:Commands.DeleteFleet">
                    <MenuItem.Icon>
                        <Image Source="/images/delete.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="_Settings" Command="fleetIt:Commands.Settings">
                    <MenuItem.Icon>
                        <Image Source="/images/wrench.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="_About" Command="fleetIt:Commands.About">
                    <MenuItem.Icon>
                        <Image Source="/images/help.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="_Version" Command="fleetIt:Commands.Version"/>
            </MenuItem>
        </Menu>
        <TextBlock Height="20" VerticalAlignment="Center" Grid.Row="2" HorizontalAlignment="Center">
            Powered by <Hyperlink Name="urlClick" Click="urlClick_Click" 
                                  NavigateUri="http://www.dotnetthoughts.net">dotnetthoughts.net</Hyperlink>

        </TextBlock>
        <StatusBar Grid.Row="3">
            <StatusBarItem Name="stbStatus" FontSize="12" Content="Welcome fleetIt"  Width="95" />
            <ProgressBar Height="15" Maximum="100" Minimum="1" Name="prgInfo" Width="265" Visibility="Hidden" />
        </StatusBar>
        <Grid Grid.Row="1" Name="splLogin"
              VerticalAlignment="Center"
              Margin="5" HorizontalAlignment="Center">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Label Target="{Binding ElementName=txtUserKey}"  Content="TeamSpace _User Key" FontSize="14" Grid.Row="1" Grid.Column="1" />
            <TextBox Name="txtUserKey" Grid.Row="2" Grid.Column="1" Width="245" />
            <Button Name="cmdLogin" Content="_SignIn" Width="55" Command="fleetIt:Commands.SignIn"  
                    Grid.Row="3" Grid.Column="1" />
            <CheckBox Name="chkRememberMe" Content="_Remember me" Grid.Row="4" Grid.Column="1" />
        </Grid>
        <Grid Grid.Row="1" Name="splFleets" Visibility="Collapsed" Margin="5">
            <Grid.Resources>
                <Style TargetType="{x:Type ListBox}">
                    <Setter Property="ItemTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <StackPanel>
                                    <StackPanel.ContextMenu>
                                        <ContextMenu>
                                            <MenuItem Header="_Reply" Command="fleetIt:Commands.ReplyToFleet">
                                                <MenuItem.Icon>
                                                    <Image Source="/images/arrow_rotate_anticlockwise.png" />
                                                </MenuItem.Icon>
                                            </MenuItem>
                                            <Separator />
                                            <MenuItem Header="_Favorite" Command="fleetIt:Commands.MarkFavoriteFleet">
                                                <MenuItem.Icon>
                                                    <Image Source="/images/star.png" />
                                                </MenuItem.Icon>
                                            </MenuItem>
                                            <Separator />
                                            <MenuItem Header="_Delete" Command="fleetIt:Commands.DeleteFleet">
                                                <MenuItem.Icon>
                                                    <Image Source="/images/delete.png" />
                                                </MenuItem.Icon>
                                            </MenuItem>
                                        </ContextMenu>
                                    </StackPanel.ContextMenu>
                                    <Border BorderBrush="WhiteSmoke" BorderThickness="1" CornerRadius="5">
                                        <Grid MinHeight="60px" VerticalAlignment="Top">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="48px" />
                                                <ColumnDefinition Width="2px" />
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                            </Grid.RowDefinitions>
                                            <StackPanel VerticalAlignment="Top" Grid.Row="0" Grid.Column="2" />
                                            <Image Grid.Column="0" 
                                               Source="{Binding Path=User.icon, Converter={StaticResource ImageCacher}}"
                                               Width="48px" Height="48px" Grid.Row="0" Grid.RowSpan="4" />
                                            <TextBlock Grid.Column="2" Foreground="Black"
                                                Width="275" TextWrapping="Wrap"
                                                Grid.Row="1" fleetItCore:NavigationService.Text="{Binding Path=text}">
                                                <TextBlock>-</TextBlock>
                                                <Hyperlink Name="lnkProfileLink" 
                                                           CommandParameter="{Binding Path=User.name}" 
                                                           Command="fleetIt:Commands.Profile" >
                                                    <TextBlock Text="{Binding Path=User.name}" />
                                                </Hyperlink>
                                            </TextBlock>
                                            <StackPanel Grid.Row="2" Grid.Column="2" Orientation="Horizontal">
                                                <Separator/>
                                                <TextBlock FontSize="10" Text="{Binding Path=from, StringFormat=via \{0\}\,\ }" />
                                                <TextBlock FontSize="10" Text="{Binding Path=updated_on, StringFormat=updated on \{0\}}" />
                                            </StackPanel>
                                        </Grid>
                                    </Border>
                                </StackPanel>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <StackPanel Grid.Row="1" Grid.ColumnSpan="3" >
                <ListBox Name="lstFleets" 
                         Opacity="65" ItemsSource="{Binding}"
                         Height="405">
                    <ListBox.Background>
                        <LinearGradientBrush>
                            <GradientStop Color="DodgerBlue" Offset="0.0" />
                            <GradientStop Color="White" Offset="0.7" />
                        </LinearGradientBrush>
                    </ListBox.Background>
                </ListBox>
            </StackPanel>
            <Separator Grid.Row="2" Grid.ColumnSpan="3"/>
            <Label Grid.Row="3" Content="What's Happening?" FontSize="12" Grid.ColumnSpan="3" />
            <ToolBar Grid.Row="4" Grid.ColumnSpan="3">
                <Button Name="cmdBold" Command="fleetIt:Commands.Bold">
                    <Image Source="/Images/text_bold.png" />
                </Button>
                <Button Name="cmdItalic" Command="fleetIt:Commands.Italic">
                    <Image Source="/Images/text_italic.png" />
                </Button>
                <Button Name="cmdUnderline" Command="fleetIt:Commands.Underline">
                    <Image Source="/Images/text_underline.png" />
                </Button>
                <Button Name="cmdStrike" Command="fleetIt:Commands.StrikeThrough">
                    <Image Source="/Images/text_strikethrough.png" />
                </Button>
                <Separator />
                <Button Name="cmdPaste" Command="fleetIt:Commands.Paste">
                    <Image Source="/Images/page_paste.png" />
                </Button>
                <Separator />
                <Button Name="cmdLink" Command="fleetIt:Commands.InsertLink">
                    <Image Source="/Images/link.png" />
                </Button>
                <Separator />
                <ComboBox Width="80px" Name="cmbSmiley" 
                          HorizontalAlignment="Left"
                          HorizontalContentAlignment="Left"
                          SelectionChanged="cmbSmiley_SelectionChanged">
                    <ComboBoxItem Selector.IsSelected="True">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Images/emoticon_smile.png" />
                            <Label>Smiley</Label>
                        </StackPanel>
                    </ComboBoxItem>
                    <ComboBoxItem Tag=":)">
                        <Image Source="/Images/emoticon_smile.png" />
                    </ComboBoxItem>
                    <ComboBoxItem Tag=":D">
                        <Image Source="/Images/emoticon_happy.png" />
                    </ComboBoxItem>
                    <ComboBoxItem Tag=";)">
                        <Image Source="/Images/emoticon_wink.png" />
                    </ComboBoxItem>
                    <ComboBoxItem Tag=":W">
                        <Image Source="/Images/emoticon_surprised.png" />
                    </ComboBoxItem>
                    <Separator/>
                    <ComboBoxItem Tag=":P">
                        <Image Source="/Images/emoticon_tongue.png" />
                    </ComboBoxItem>
                    <ComboBoxItem Tag=":(">
                        <Image Source="/Images/emoticon_unhappy.png" />
                    </ComboBoxItem>
                </ComboBox>
            </ToolBar>
            <TextBox Name="txtFleet" Height="50px" Grid.ColumnSpan="3" Grid.Row="5"
                     TextWrapping="Wrap"
                     AcceptsReturn="True"
                     SpellCheck.IsEnabled="True"
                     VerticalScrollBarVisibility="Visible" />
            <TextBlock Width="100px" Grid.Row="6" Grid.Column="0" 
                       Foreground="{Binding ElementName=txtFleet, Path=Text.Length, Converter={StaticResource CharacterCounter}}"
                   Text="{Binding ElementName=txtFleet, Path=Text.Length, StringFormat=\{0\} Chars}" />
            <Button Name="cmdFleetMyStatus"
                    Command="fleetIt:Commands.FleetMyStatus"
                    Grid.Row="7" Grid.Column="2" Content="Fleet My Status" Width="100px">
            </Button>
        </Grid>
    </Grid>
</Window>